package collecttion;

import java.util.ArrayList;
import java.util.List;

//List重载了一对add,remove方法
public class ListDemo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println("list:"+list);

        list.add(3,"six");//插入元素操作，在下标为3的位置插入six
        System.out.println(list);//[one, two, three, six, four, five]

        String old = list.remove(2);//删除并返回指定位置的元素
        System.out.println(list);//[one, two, six, four, five]
        System.out.println(old); //返回值three
    }
}
